package com.itheima.d3_inner_class3;

/*
    1 匿名内部类在开发中的使用场景
        通常作为一个参数传输给方法。

 */
public class Test2 {
    public static void main(String[] args) {
        MaHu maHu = new MaHu();
        System.out.println("开始");
        maHu.swim();
        System.out.println("结束");

        Swimming swimming = new Swimming() {
            @Override
            public void swim() {
                System.out.println("仰泳");
            }
        };
        swimming.swim();
        SwimGame(new Swimming() {
            @Override
            public void swim() {
                System.out.println("狗会狗刨");
            }
        });


    }

    public static void SwimGame(Swimming s) {
        System.out.println("开始");
        s.swim();
        System.out.println("结束");
    }

}


interface Swimming {
    void swim();
}

class MaHu implements Swimming {
    @Override
    public void swim() {
        System.out.println("马户会游泳");
    }
}
